<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button id="btn">点击抽奖</button>
    <script>
        function rand(a,b){
            return Math.ceil(Math.random()*(b-a+1)) + a-1;
        }
        let btn = document.querySelector('#btn');
        btn.onclick = function(){
            let p = new Promise((resolve,reject)=>{
                let num = rand(1,5)
                if(num < 30){
                    resolve(num)
                }else{
                    reject(num)
                }
            })
            p.then(velue=>{
                console.log('恭喜中奖'+velue);
            },reason=>{
                console.log('谢谢惠顾'+reason);
            })
        }
    </script>
</body>
</html>